]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
inputMethod: Update to set_preedit_text() API change
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 18 Jul 2022 13:11:49 +0000 (15:11 +0200)
committerMarge Bot <marge-bot@gnome.org>
Tue, 19 Jul 2022 12:20:28 +0000 (12:20 +0000)
Since IBus does not provide this information right away, we
so far cannot do much about providing a truthful anchor position
for the preedit text. But with the Mutter API in place it will
be up to this object to do so in the future.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2384>

js/misc/inputMethod.js

index 8c3cd61aeb8387199866809ebdf1bbf73deb6d02..856bf57aecd855689878a7eaa99d93d64ec63628 100644 (file)
@@ -18,6 +18,7 @@ class InputMethod extends Clutter.InputMethod {
         this._currentFocus = null;
         this._preeditStr = '';
         this._preeditPos = 0;
+        this._preeditAnchor = 0;
         this._preeditVisible = false;
         this._hidePanelId = 0;
         this._ibus = IBus.Bus.new_async();
@@ -85,6 +86,7 @@ class InputMethod extends Clutter.InputMethod {
         this._purpose = 0;
         this._preeditStr = '';
         this._preeditPos = 0;
+        this._preeditAnchor = 0;
         this._preeditVisible = false;
     }
 
@@ -114,24 +116,30 @@ class InputMethod extends Clutter.InputMethod {
         if (preedit === '')
             preedit = null;
 
+        const anchor = pos;
         if (visible)
-            this.set_preedit_text(preedit, pos, mode);
+            this.set_preedit_text(preedit, pos, anchor, mode);
         else if (this._preeditVisible)
-            this.set_preedit_text(null, pos, mode);
+            this.set_preedit_text(null, pos, anchor, mode);
 
         this._preeditStr = preedit;
         this._preeditPos = pos;
+        this._preeditAnchor = anchor;
         this._preeditVisible = visible;
         this._preeditCommitMode = mode;
     }
 
     _onShowPreeditText() {
         this._preeditVisible = true;
-        this.set_preedit_text(this._preeditStr, this._preeditPos, this._preeditCommitMode);
+        this.set_preedit_text(
+            this._preeditStr, this._preeditPos, this._preeditAnchor,
+            this._preeditCommitMode);
     }
 
     _onHidePreeditText() {
-        this.set_preedit_text(null, this._preeditPos, this._preeditCommitMode);
+        this.set_preedit_text(
+            null, this._preeditPos, this._preeditAnchor,
+            this._preeditCommitMode);
         this._preeditVisible = false;
     }
 
@@ -169,7 +177,7 @@ class InputMethod extends Clutter.InputMethod {
 
         if (this._preeditStr && this._preeditVisible) {
             // Unset any preedit text
-            this.set_preedit_text(null, 0, this._preeditCommitMode);
+            this.set_preedit_text(null, 0, 0, this._preeditCommitMode);
             this._preeditStr = null;
         }